package com.icss.clothes.mapper;

import com.icss.clothes.entity.Shopdetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface ShopDetailMapper {
    //从数据库中通过指定的商品编号、尺码编号、颜色编号查询得到商品详情信息
    @Select("select * from commodity_detail where c_id=#{c_id} and size_id=#{size_id} and color_id=#{color_id}")
    public Shopdetail selectAll(int c_id,int size_id,int color_id);
    //从数据库中通过指定的商品详情编号获取得到商品详情信息
    @Select("select * from commodity_detail where cd_id=#{cd_id}")
    public Shopdetail selectAllByCd_id(int cd_id);
    //从数据库中修改指定的商品的商品库存
    @Update("update commodity_detail set c_number=c_number-#{od_number} where cd_id=#{cd_id}")
    public void updateC_numberByCd_id(@Param("cd_id") int cd_id,
                                      @Param("od_number") int od_number);
    //从数据库中通过指定的商品编号修改指定的商品库存
    @Update("update commodity_detail set c_number=c_number+#{od_number} where cd_id=#{cd_id}")
    public void updateNumberByCd_id(@Param("cd_id") int cd_id,
                                    @Param("od_number") int od_number);
}
